const vuemethod = {

    loadToken() {
        this.tokenJson = tool.parseTokenObject(this.tokenObject)
    },

    submitForm() {
    this.$refs.formRef.validate((valid) => {
        if (valid) {

            // 创建一个 axios 实例
            const instance = axios.create({
                baseURL: this.pre
            });

            // 动态设置请求头
            instance.defaults.headers.common['Authorization'] = 'Bearer ' + 'Wang-Zhou-Token:' + this.tokenJson.tokenJwt ;

            // TODO: gcc
            instance.post("/" + this.a + "/" + this.b + "/" + this.c + "/" + "generate", this.formData)
                .then((response) => {
                    if (response.data.code === 200) {
                        this.$message.success('生成成功');
                        this.handleClose();
                        this.loadTableData();
                    } else {
                        this.$message.error(response.data.msg);
                    }
                })
                .catch((error) => {
                    this.$message.error('生成失败');
                });
        } else {
            return false;
        }
    });
},


    searchByFilter() {},
    // 切换菜单折叠状态
    toggleCollapse() {
    this.isCollapse = !this.isCollapse;
},
    // 添加菜单点击处理方法
    handleSelect(index, indexPath) {
    this.activeMenu = index;
    // 根据需要处理路由跳转或其他逻辑
},

    handleSizeChange(val) {
    this.pagination.pageSize = val;
    this.loadTableData();
},
    handleCurrentChange(val) {
    this.pagination.currentPage = val;
    this.loadTableData();
},
    generateCode(row) {
    //
    // this.formData = row ;
    //
    // this.codeTypeToForm = row.codeType.split(',');

    this.dialogVisible = true
},
    dialogFormSubmit() {},

    handleView(row) {
    // TODO: 实现查看功能
},
    handleDelete(row) {
    this.$confirm('确认删除<span style="color:red;">小区信息</span>吗？', '提示', {
        dangerouslyUseHTMLString: true,
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
    }).then(() => {
        // TODO: 实现删除功能
        this.$message.success('删除成功');
    }).catch(() => {});
},
    loadTableData() {

    this.tokenJson = JSON.parse(this.tokenObject.replace(/&quot;/g, '"')) ;

    axios.get(this.pre + "/" + this.a + "/" + this.b + "/" + this.c + "/" + "page", {
        params: {
            cpage: this.pagination.currentPage,
            csize: this.pagination.pageSize
        },
        headers: {
            'Authorization': 'Bearer ' + 'Wang-Zhou-Token:' + this.tokenJson.tokenJwt
        }
    })
        .then((response) => {
            if (response.data.code === 200) {
                const info = response.data.data;
                this.tableData = info.list;
                this.pagination.total = info.total;
            } else {
                this.$message.error(response.data.msg);
            }
        })
},
    showMessages() {
    // TODO: 显示消息列表
    this.$message({
        message: '您有3条未读消息',
        type: 'info'
    });
},
    logOutPage() {
    window.location.href = '/pc' + '/login';
},
    clearCompletedTodos() {
    this.todos = this.todos.filter(todo => !todo.done);
},
    loadMenus() {
    axi.get(this, '/auth/sysinfo/menu/' + 'sidebar' + '/' + this.sysinfoMicroId , {}, data => {
        if (data && data.length > 0) {
            this.menuList = data
        }
    })
},
    openUrl(dir, item) {
        const tmp = "fc6ffcc43019b074f54f4b0de831257bc087a0c6f7c6f310267b23c258068c80Ab5e09fa288c363d73f894e08a0dcc3eb0fa830a0862dda8093dc60211cf802ac"
        const last = this.pre + '/html/' + this.a + '/' + dir.url + '/' + item.url + '/' + this.tokenJson.token + "A" + tmp + "?t=" + new Date().getTime() + "&sysinfoMicroId=" + this.sysinfoMicroId
        window.location.href = last
    },
    goHomePage() {
        const tmp = "fc6ffcc43019b074f54f4b0de831257bc087a0c6f7c6f310267b23c258068c80Ab5e09fa288c363d73f894e08a0dcc3eb0fa830a0862dda8093dc60211cf802ac"
        const last = this.pre + '/html/' + this.a  + this.abc.micro.root + '/' + this.tokenJson.token + "A" + tmp + "?t=" + new Date().getTime() + "&sysinfoMicroId=" + this.sysinfoMicroId
        window.location.href = last;
},
    copyById(id) {
    this.$message.info(id)
},

    trans(row) {
    const res = tool.objToKvList(row)
    return res;
},

    loadRole() {
    axi.get(this,  '/auth/sysinfo/role' + '/role_by_token_id/' + this.tokenJson.id  , {},  data => {
        if (data) {
            this.role = data ;
        }
    })
},

    handlePasteTableName(event) {
    //
    if (this.formData.tableName && this.formData.tableName.indexOf('_') > -1) {
        const item = this.formData.tableName.trim().toLowerCase().split('_');
        if (item.length >= 3 && item[2].trim() != '') {
            // this.formData.microName = item[0].trim();
            this.formData.module = item[1].trim();
            this.formData.entity = item[2].trim();
            //
            // big
            const be = item[1].trim().charAt(0).toUpperCase() + item[1].trim().slice(1);
            const tmp = item.slice(2).map(_ => _.charAt(0).toUpperCase() + _.slice(1)).join('');
            this.formData.javaEntity = be + tmp ;

            //
            this.formData.url = "/" + this.formData.sysinfoMicro.route + '/' + item[1].trim() + '/' + item.slice(2).join("_")

            //
            this.formData.tableMean = from.formData.tableName
        }
    }

},

        handleClose() {
            this.$refs.formRef.resetFields();
            this.dialogVisible = false;
        },


    elForm() {},


}
